package com.rd.student.jiaji.class2.duyukun.Day0808;

import com.rd.student.ruanjian.class1.duhang.NewNew0803.Array;

import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.Writer;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

public class TestStudent {
    public static void main(String[] args) throws IOException {
        Scanner scanners = new Scanner(System.in);
        System.out.println("请输入本次录入的学生人数：");
        int str = scanners.nextInt();


        File file = new File("Student.txt");
        FileWriter writer = new FileWriter(file);
        writer.write("姓名 " + "语文成绩 " + "数学成绩 " + "总成绩");


        for (int i = 0; i < str; i++) {
            Scanner scanner = new Scanner(System.in);
            System.out.println("请输入学生姓名：");
            String name = scanner.nextLine();

            Scanner scanner1 = new Scanner(System.in);
            System.out.println("请输入语文成绩:");

            int chinese = scanner1.nextInt();
            while (chinese > 100 || chinese < 0) {
                System.out.println("输入错误！");
                return;
            }

            Scanner scanner2 = new Scanner(System.in);
            System.out.println("请输入数学成绩：");
            int math = scanner2.nextInt();
            while (math > 100 || math < 0) {
                System.out.println("输入错误！");
                return;
            }

            Student student = new Student();

            student.Student(name,chinese,math);
            student.setName(name);
            student.setChinese(chinese);
            student.setMath(math);
            int all = chinese + math;
            student.setAll(all);

            writer.write("/n" + student.getName() + " " + student.getChinese() + " " + student.math + " " + student.getAll());


            System.out.println("请输入下一个学生");
        }
        writer.close();


    }

}
